/**
 @Name：layuiAdmin 开标项目列表
 @Author：star1029 
 @License：LPPL    
 */
layui.define(['table', 'form'], function(exports){
  var $ = layui.$
  ,table = layui.table
  ,form = layui.form
  ,upload = layui.upload;

  //帖子管理
  table.render({
    elem: '#LAY-app-projectdetailbdunit-list'
    ,url: layui.setter.base + 'json/projectdetailbdunit/list.js' //模拟接口
    ,cols: [[
      {type: 'checkbox', fixed: 'left'}
      ,{field: 'id', width: 100, title: 'ID', sort: true}
      ,{field: 'XMMC', title: '项目名称', sort: true  }    
      ,{field: 'BidTitle', title: '标段名称', sort: true }
      ,{field: 'unitname', title: '投标单位名称', sort: true }
      ,{field: 'BidApplyTime', title: '标书递交时间', sort: true }
      ,{field: 'Bidprice', title: '投标报价', edit: 'text'}
      ,{field: 'XMMCleader', title: '项目负责人',edit: 'text'}
      ,{fixed : 'right',align : 'center',title : '上传标书', templet : function (d) {  
        var uploadBtn='<shiro:hasPermission name="system:hkWeldingProcedurce:upload upload_hk"><button class="layui-btn layui-btn-xs layui-btn-primary" lay-event="upload" id="upload-'+d.id+'" type="button" value="'+d.id+'">上传</button></shiro:hasPermission>';
        var reBtn=uploadBtn;
            return reBtn;
    }}
    ]]
    ,page: true
    ,limit: 10
    ,limits: [10, 15, 20, 25, 30]
    ,text: '对不起，加载出现异常！'   
  });  
  //监听工具条
  table.on('tool(LAY-app-projectdetailbdunit-list)', function(obj){
    var data = obj.data;
    var uploadobj= "#upload-"+data.id;
   // console.log((obj.tr.find('.upload_hk')))
    if(obj.event =="upload")
    {
      upload.render({ //允许上传的文件后缀
        //elem: obj.tr.find('.upload_hk')
        elem:uploadobj
        ,url:'/upload/' //改成您自己的上传接口
        ,accept: 'file' //普通文件
        ,done: function(res){
          layer.msg('上传成功');
        } 
        ,error: function(index, upload){   
          layer.msg('上传失败，请重试');
      }
      });

    }

  });
    //监听单元格编辑
    table.on('edit(projectdetailbdunit)', function(obj){
      var value = obj.value //得到修改后的值
      ,data = obj.data //得到所在行所有键值
      ,field = obj.field; //得到字段
      layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改值为：'+ util.escape(value));
    });

  exports('projectdetailbdunit', {})
});